package com.xinyu.shopping_common.exception;

import com.xinyu.shopping_common.enums.CodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 业务异常类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BusException extends RuntimeException {
    // 状态码
    private Integer code;
    // 错误消息
    private String msg;

    public BusException(CodeEnum codeEnum){
        this.code = codeEnum.getCode();
        this.msg = codeEnum.getMessage();
    }

    public static void main(String[] args) {
        BusException busException = new BusException(CodeEnum.PARAMETER_ERROR);
        System.out.println("busException = " + busException);
        System.out.println("busException.getMsg() = " + busException.getMsg());
    }
}
